<?xml version="1.0" encoding="utf8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="doc_title"/> 
<xsl:param name="doc_text"/>
<xsl:param name="warnings"/>
<xsl:param name="admin_view"/>
  <xsl:template match="/">     
    <html>
      <head>
        <title>XSLT Processor</title>
        <link rel="stylesheet" type="text/css" href="main.css"/>
        <script type="text/javascript" src="prototype.js"></script>
        <script type="text/javascript" src="main.js"></script>
      </head>
      <body>
        <div class='header'>
          <p class='requested-file'>requested file: <xsl:value-of select="$doc_title"/></p>
          <xsl:if test="$warnings">
            <h3 class='warnings'><xsl:value-of select="$warnings"/></h3>
          </xsl:if>
        </div>
        <table class='menu'>
          <tr>
            <td> <a href='toc.php'>table of contents</a> </td>
            <xsl:choose>
              <xsl:when test="$admin_view = 'true'">
                <td> <button id='toggle-read-edit'>toggle read/edit content</button> </td>
                <td><a href='logout.php'>log out</a></td>
              </xsl:when>
              <xsl:otherwise>
                <td><a href='login.php'>log in</a></td>
              </xsl:otherwise>
            </xsl:choose>
          </tr>
        </table>

        <div id='content-main'>
          <xsl:copy-of select="."/>
        </div>

        <div id='content-form'>
          <form method='post' action='update.php'>
            <p><textarea name='content-text' rows='15' cols='100'><xsl:copy-of select='$doc_text'/></textarea></p>
            <input type='hidden' name='content-title' value='{$doc_title}'/>
            <p><input type='submit' value='update'/></p>
          </form>  
        </div>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>  
